/*将js对象(字母大写)属性名转换为下划线*/
function strAllReplaceLine(new_obj){
    let arr = [];
    var result = strAllReplace(new_obj);
    return result;
    function strReplace(str) {
        const UP_CASE_REG =/[A-Z]/g;
        const NUMBER_REG=/[A-Za-z][\d]/g
        let newstr = ""
        getIndex(UP_CASE_REG, str)
        getIndex(NUMBER_REG, str)
        arr.sort((a,b)=> a-b )
        for(let i = 0;i < arr.length; i ++) {
            if(i === 0) {
                newstr += str.slice(0,arr[i]) + "_"
            }
            else {
                newstr += str.slice(arr[i-1],arr[i]) + "_"
            }
        }
        newstr += str.slice(arr[arr.length-1])
        return newstr.toLowerCase()
    }
    function getIndex(reg, str) {
        do{
            reg.test(str)
            if(reg.lastIndex !== 0 && reg.lastIndex-1 !== 0){//reg.lastIndex-1 !== 0判断首字母是否大写
                arr.push(reg.lastIndex-1)
            }
        }while(reg.lastIndex > 0)
    }

    function strAllReplace(obj) {
        let newObj = {}
        Object.entries(obj).forEach(([key, value]) =>
        {
            newObj[strReplace(key)] = value
            arr = []
        })
        return newObj
    }
}